package cn.houseProperty.contoller;

import cn.entity.Do.Building;
import cn.entity.Status;
import cn.houseProperty.service.impl.BuildingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin/building")
public class BulidingContoller {
    @Autowired
    private BuildingService buildingService;
    @ResponseBody
    @GetMapping("/getBuildingByPid")
    public Status getBuildingByPid(String pid){
        Status status = new Status();
        status.setFlag(true);
        status.setData(buildingService.selectByPid(pid));
        return status;
    }

    @ResponseBody
    @GetMapping("/selectAll")
    public Status selectAll(){
        Status status = new Status();
        List<Building> buildings = buildingService.selectAll();
        if(buildings!=null){
            status.setFlag(true);
            status.setData(buildings);
            return status;
        }else {
            status.setFlag(false);
            status.setMessage("错误");
            return status;
        }
    }
}
